package com.essence.common.model;

import com.essence.common.model.parser.*;

import java.util.HashMap;
import java.util.Map;

public class ASDUParserFactory {
    private static final Map<Packet.TieIdentificationEnum, InfoObjectParser> parsers = new HashMap<>();

    static {
        parsers.put(Packet.TieIdentificationEnum.C_SC_NA_1, new CScNaParser());
        parsers.put(Packet.TieIdentificationEnum.C_SC_NB_1, new CScNbParser());
        parsers.put(Packet.TieIdentificationEnum.M_SP_NA_1, new MSpNaParser());
        parsers.put(Packet.TieIdentificationEnum.M_DP_NA_1, new MSpNaParser());
        parsers.put(Packet.TieIdentificationEnum.C_SE_NA_1, new CSeNaParser());
        parsers.put(Packet.TieIdentificationEnum.C_SE_NB_1, new CSeNbParser());
        parsers.put(Packet.TieIdentificationEnum.C_SE_NC_1, new CSeNcParser());
        parsers.put(Packet.TieIdentificationEnum.M_DP_TB_1, new MDpTbParser());
        parsers.put(Packet.TieIdentificationEnum.M_SP_TB_1, new MSpTbParser());
        parsers.put(Packet.TieIdentificationEnum.M_ME_NA_1, new MMeNaParser());
        parsers.put(Packet.TieIdentificationEnum.M_ME_NB_1, new MMeNbParser());
        parsers.put(Packet.TieIdentificationEnum.M_ME_NC_1, new MMeNcParser());
        parsers.put(Packet.TieIdentificationEnum.C_DC_TA_1, new CDcTaParser());
        parsers.put(Packet.TieIdentificationEnum.C_SC_TA_1, new CScTaParser());
    }

    public static InfoObjectParser GetParser(Packet.TieIdentificationEnum tieIdentification) {
        return parsers.getOrDefault(tieIdentification, null);
    }
}
